
/**
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file. 
 *
 * @File name:  TSystemUserDao.java 
 * @Create on:  2012-06-25 21:04:407
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */

package com.boho.ecp.manage.user.dao;

import java.sql.Connection;
import java.util.LinkedList;
import java.util.List;

import cn.boho.framework.po.CQuery;
import cn.boho.framework.po.CQueryFactoryTool;
import cn.boho.framework.po.ComboPager;
import cn.boho.framework.po.DAO;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.po.Pager;

/**
 * 【系统用户信息:T_SYSTEM_USER】的Dao操作类
 * 
 */
public class TSystemUserDao extends DAO {
	/**
	 * 查询所有【系统用户信息:T_SYSTEM_USER】信息
	 * 
	 * @param con
	 * @return
	 * @throws Exception
	 * @date 2012-06-25
	 * @author 陈伟
	 * 
	 */
	public static List queryTSystemUser(Connection con) throws Exception {
		List list = new LinkedList();
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_SYSTEM_USER");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		list = query.getDynaBeanMapList("T_SYSTEM_USER", con);
		return list;
	}

	/**
	 * 分页查询所有【系统用户信息:T_SYSTEM_USER】信息
	 * 
	 * @param con
	 * @param pager
	 * @return
	 * @throws Exception
	 * @date 2012-06-25
	 * @author 陈伟
	 * 
	 */
	public static ComboPager queryTSystemUserByPager(Connection con, Pager pager) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_SYSTEM_USER where IS_VALID = 1 order by CREATE_DATE");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		return query.getDynaBeanMapComboPager("T_SYSTEM_USER", pager, con);
	}

	/**
	 * 根据主键【系统用户编号:SYSTEM_USER_ID|】获得信息
	 * 
	 * @param con
	 * @param systemUserId
	 *            系统用户编号
	 * @return
	 * @throws Exception
	 * @date 2012-06-25
	 * @author 陈伟
	 * 
	 */
	public static DynaBeanMap getTSystemUserByPk(Connection con, java.lang.Integer systemUserId) throws Exception {
		DynaBeanMap dynaBeanMap = null;
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_SYSTEM_USER where  SYSTEM_USER_ID=? and IS_VALID = 1");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setInt(1, systemUserId);
		dynaBeanMap = query.getDynaBeanMap("T_SYSTEM_USER", con);
		return dynaBeanMap;
	}
	
	/**
	 * 根据主键【系统用户编号:SYSTEM_USER_ID|】获得信息
	 * 
	 * @param con
	 * @param systemUserId
	 *            系统用户编号
	 * @return
	 * @throws Exception
	 * @date 2012-06-25
	 * @author 陈伟
	 * 
	 */
	public static DynaBeanMap getTSystemUserByLogin(Connection con, java.lang.String name, String password) throws Exception {
		DynaBeanMap dynaBeanMap = null;
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_SYSTEM_USER where LOGIN_NAME= ? and PASSWORD = ? and IS_VALID = 1");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setString(1, name);
		query.setString(2, password);
		dynaBeanMap = query.getDynaBeanMap("T_SYSTEM_USER", con);
		return dynaBeanMap;
	}

}
